%this function gives for a given gain in dB of the PDA100A
%the conversion factor from Voltage to power as follows:

%power=vol_to_pow_coef*Voltage

 %careful, responsivity is at 780nm!!
 
 %load =50 for 50ohm or 1  for HiZ

   %I write gain for HiZ, 
        %factor to convert to 50ohm loads has been taken
        %into account in the load_gain_factor
 
 %power=Voltage/(load_factor*responsivity*gain)    from Thorlabs
function vol_to_pow_coef=PDA100A_coef(load,gain_in_dB)

        if load== 50
       load_gain_factor=1/4;
    end
    if load==1%for hiZ load
       load_gain_factor=1; 
    else
       error=(['the firt argument has to be  either 50 or  1 for 50ohm loads or 1 fo Hi impedance load respectively'])
    end

    responsivity=0.5;
    
    %almost 1.51e+3*10* pi^gain/10 :D
    if mod(gain_in_dB,2) == 0  
        gain=1.51*10^((gain_in_dB+60)/20);
    else
        
        gain=4.75*10^((gain_in_dB+50)/20);
    end
    
    vol_to_pow_coef=1/(load_gain_factor*responsivity*gain);
    
end